App({
  globalData: {
    isConnected: false,
    isBluetoothReady: false, // 蓝牙适配器是否可用
    connectedDevice: null,
    userInfo: null,
    serviceId: null,
    characteristicId: null,
    notifyId:null
  },

  onLaunch() {
    // 检查蓝牙是否可用
    wx.getSystemInfo({
      success: (res) => {
        if (!res.bluetoothEnabled) {
          wx.showModal({
            title: '提示',
            content: '请打开蓝牙',
            showCancel: false
          })
        }
      }
    })
  },

  // 保存连接的设备信息
  setConnectedDevice(device) {
    this.globalData.connectedDevice = device
    alert('已设置蓝牙设备')
  },

  // 清除连接的设备信息
  clearConnectedDevice() {
    this.globalData.connectedDevice = null
  }
}) 